//
//  InitializerViewController.swift
//  SwiftTest
//
//  Created by midea on 16/3/17.
//  Copyright © 2016年 Vincent. All rights reserved.
//

import Foundation

struct Vechile {
    var person : Int64
    init(){
        person = 45
    }
}

class Car {
    var CarDrvier : String
    init (withDriver driver:String){
        CarDrvier = driver
    }
}

class Truck {
    var TruckDriver : String
    var Truckweight : Float
    init(withDriver driver:String,andWeight weight:Float){
        TruckDriver = driver
        Truckweight = weight
    }
}

struct Color {
    var red = 0.0, green = 0.0, blue = 0.0
    init(red: Double, green: Double, blue: Double) {
        self.red   = red
        self.green = green
        self.blue  = blue
    }
}

struct Fruit {
    var apple : String
    var banana : String?
    init(){
        self.apple = "big apple"
    }
}

class Food {
    var name : String
    init (name:String){
        self.name = name
    }
    
    convenience init(){
        self.init(name:"chicken")
    }
}

class RecipeIngredient : Food {
    var quantity : Int64
    init(name: String,quantity:Int64) {
        self.quantity = quantity
        super.init(name: name)
    }
    
    convenience override init(name: String) {
        self.init(name:name,quantity:10)
    }
}

class InitializerViewController : BaseViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let vechile = Vechile()
        print("This vechile has " + String(vechile.person) + " persons")
        
        let car = Car.init(withDriver: "Michael")
        print("This car's driver is " + car.CarDrvier)
        
        let truck = Truck.init(withDriver: "Michele", andWeight: 4.5)
        print("This truck's driver is " + truck.TruckDriver + " and weigth is " + String(truck.Truckweight) + "t")
        
        let color = Color.init(red: 0.3, green: 0.4, blue: 0.5)
        print(color)
        
        let fruit = Fruit()
        print(fruit)
        
        let food1 = Food.init(name: "meet")
        print(food1.name)
        
        let food2 = Food.init()
        print(food2.name)
        
        let recipeIngredient1 = RecipeIngredient.init(name: "cow", quantity: 500)
        print(recipeIngredient1.name + String(recipeIngredient1.quantity))
        
        let recipeIngredient2 = RecipeIngredient.init(name: "bee")
        print(recipeIngredient2.name + String(recipeIngredient2.quantity))
    }
}